package com.tms.app.tms.ui;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.tms.app.tms.R;
import com.tms.app.tms.TestActivity;
import com.tms.app.tms.ui.home.MainActivity;
import com.tms.app.tms.utils.SharePreferenceUtil;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by Administrator on 2017/10/28 0028.
 */

public class GuideActivity extends AppCompatActivity {
    boolean isFrist=true;
    private int startType=1;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.guide);
        isFrist= SharePreferenceUtil.getBoolean(this,"isFrist",true);
        TimerTask task = new TimerTask()
        {
            public void run()
            {
                checkFrist();
            }
        };
        Timer timer = new Timer();
        timer.schedule(task,100);
    }


    private void checkFrist(){
        Intent intent=null;
        if (isFrist){
            startType=0;
            SharePreferenceUtil.setValue(this,"isFrist",false);
        }
        if (!SharePreferenceUtil.getString(this,"token","").equals("")){
            startType=1;
        }

//        startType=4;
        switch (startType){
            case 0:
                intent=new Intent(this,WelcomeActivity.class);
                intent.putExtra("targetType",0);
                break;
            case 1:
                intent=new Intent(this,AutoLoginActivity.class);
                intent.putExtra("type",startType);
                break;
            case 2:
                intent= new Intent(this, MainActivity.class);
                break;
            case 3:
                intent= new Intent(this, cn.edu.zafu.camera.CameraBaiDuActivity.class);
                break;
            case 4:
                intent=new Intent(this,WelcomeActivity.class);
                intent.putExtra("targetType",1);
                break;
            case 5:
                intent=new Intent(this, TestActivity.class);
                break;
        }
        startActivity(intent);
        finish();
    }

}
